<?php
/**
 * Created by PhpStorm.
 * User: sunshine
 * Date: 2016/8/30
 * Time: 20:33
 */
require_once "Admin/Controller/Controller.php";
require_once "Admin/Model/TypeModel.php";
class TypeController extends Controller
{function __Construct(){
    parent::__Construct();

}

    function typelist()
    {
        if (isset($_SESSION['admin'])) {
            $model = new TypeModel();
            $data = $model->getTypeList();
            $this->assign('type', $data);
            $this->display();
        }
    }

    function form(){
        if (isset($_SESSION['admin']))
        $this->display();
    }
    function add()
    {
        if (isset($_SESSION['admin'])) {
            $data = $_POST;
            $model = new TypeModel();
            $result = $model->addType($data);
            if ($result) {
                echo '添加成功 <a href="admin.php?c=type&m=typelist">如果没有跳转，请点这里跳转</a>';
                header("refresh:3;url='admin.php?c=user&m=typelist'");
            } else {
                echo "添加失败！<br/>";
                header("refresh:3;url='admin.php?c=user&m=form'");
            }
        }
    }
}
?>